package spring.yongongsystem.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import spring.yongongsystem.POJO.dto.OrderDTO;
import spring.yongongsystem.POJO.dto.OrderPageQueryDTO;
import spring.yongongsystem.POJO.entity.Order;
@Mapper
public interface OrderMapper{
    /**
     * 分页查询订单
     *
     * @param orderPageQueryDTO
     * @return
     */
    Page<OrderDTO> pageQuery(OrderPageQueryDTO orderPageQueryDTO);

    /**
     * 插入订单
     * @param order
     */
    @Insert("insert into `order` (merchant_id, worker_id, product_id, order_status, number,photo)" +
            " VALUES" +
            " (#{merchantId},#{workerId},#{productId},#{orderStatus},#{number},#{photo})")
    void insert(Order order);
    @Delete("delete from `order` where id = #{id}")
    void deleteById(Long id);

    @Select("select * from `order` where id = #{orderId}")
    Order getById(Long orderId);

    void update(Order order);

    @Select("SELECT COUNT(*) FROM `order`;")
    long count();
}